package SOEN_Phase_3;

import junit.framework.TestCase;
import junit.framework.Assert;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;

import java.util.ArrayList;

public class PersonTest extends TestCase {
	
	public void testHashCode() {
		Person d = new Person ("fdf", 456);
		
		int f = d.getID();
		int g = 456;
		
		assertEquals(g,f);
		
	}

	public void testPerson() {
		Person lok = new Person ("Test", 123);
		boolean good = false;
		if ((lok.getName() == "Test")&& (lok.getID() == 123))
			good = true;
		
		assertTrue(good);
	}

	public void testToGUIEntry() {
		Person test = new Person ("name", 123);
		String[] act = test.toGUIEntry();
		String[] exp = {"123", "", "0"};
		
		for(int i = 0; i < exp.length; i++)
		{
			assertEquals(true, act[i].equalsIgnoreCase(exp[i]));
		}
	}

	public void testAddTask() {
		
		ArrayList<Task> a = new ArrayList<Task>();
		ArrayList<Integer> b = new ArrayList<Integer>();
		Task g = new Task(12,5,"title","name", 5, 0, false, a, b);
		Task f = new Task(13,8,"bird", "name",5,0,false,a, b);
		Person p = new Person("name",5);
		p.addTask(f);
		p.addTask(g);
		
							
		int h = p.getHours();
		assertTrue("Problem with calculateHours",h==13);	//to assure that calculateHours is correct
		
		ArrayList<Task> k = new ArrayList<Task>(2);
		
		k = p.getTasks();
		
		Task fPrime = k.get(0);
		Task gPrime = k.get(1);
		
		boolean eff =(
		(fPrime.getAssignee().equalsIgnoreCase(f.getAssignee()))&&
		(fPrime.getAssigneeID() == f.getAssigneeID())&&
		(fPrime.getDuration() == f.getDuration())&&
		(fPrime.getCompletion() == f.getCompletion())&&
		(fPrime.getID() == f.getID())&&
		(fPrime.getSubtasks() == f.getSubtasks())&&
		(fPrime.getTimeInvested() == f.getTimeInvested())&&
		(fPrime.getTitle().equalsIgnoreCase(f.getTitle())) 
				);
		
		boolean gee =(
				(fPrime.getAssignee().equalsIgnoreCase(f.getAssignee()))&&
				(fPrime.getAssigneeID() == f.getAssigneeID())&&
				(fPrime.getDuration() == f.getDuration())&&
				(fPrime.getCompletion() == f.getCompletion())&&
				(fPrime.getID() == f.getID())&&
				(fPrime.getSubtasks() == f.getSubtasks())&&
				(fPrime.getTimeInvested() == f.getTimeInvested())&&
				(fPrime.getTitle().equalsIgnoreCase(f.getTitle())) 
						);
		
		
		
		//boolean test = ((f==fPrime)&&(g==gPrime));
		assertTrue("Problem with addTask", eff == gee);
	}

	public void testEqualsObject() {
		Person one = new Person("Smith",154);
		Person two = new Person("Smith", 154);
		
		boolean test = one.equals(two);
		
		assertTrue(test);
	}

}
